str_source = '我是Tohmas Andson，你好！'
print(str_source)
byte_encoded = str_source.encode()
print('encoded(utf8): ', byte_encoded)
str_decoded = byte_encoded.decode()
print('decoded: ', str_decoded)

for encoding in ['utf8', 'utf16', 'utf_16_be', 'utf_16_le', 'gbk', 'gb2312', 'gb18030']:
    print(encoding, '-' * 32)
    byte = str_source.encode(encoding)
    print('encoded: ', byte)
    decoded = byte.decode(encoding)
    print('decoded: ', decoded)

# UnicodeDecodeError: 'utf-8' codec can't decode byte 0xce in position 0: invalid continuation byte
str_decoded_gbk_wrong = byte.decode()
print('encoded by', encoding, 'but decoded by utf8', str_decoded_gbk_wrong)
